package org.zhxy.zhxy.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

/**
 * 发送验证码工具类
 *
 * @author pxx
 */
@Component
public class SendEmailUtil {

    @Autowired
    private JavaMailSender javaMailSender;

    public void sendEmail(String from, String to, String subject, String text) {
        //SimpleMailMessage对象，用于创建简单的邮件消息
        SimpleMailMessage message = new SimpleMailMessage();
        //发送到
        message.setTo(to);
        //发送者邮箱
        message.setFrom(from);
        //主题
        message.setSubject(subject);
        //正文
        message.setText(text);
        //发送
        javaMailSender.send(message);
    }

}
